Skip to content

Avoid per-row Enumerator#next in CSV#each#362

Closed
donoghuc wants to merge 1 commit into
ruby:mainfrom
donoghuc:jruby-improvement
Closed

Avoid per-row Enumerator#next in CSV#each#362
donoghuc wants to merge 1 commit into
ruby:mainfrom
donoghuc:jruby-improvement

Conversation

@donoghuc

Copy link
Copy Markdown

External iteration via Enumerator#next uses a Fiber, cheap on CRuby but Fiber-per-row (native thread) on JRuby, so CSV.parse_line and CSV#each are ~10x slower there. Drive the parser with a block on fresh iteration; keep Enumerator#next only when #shift/#peek already started pull-based iteration, preserving shared consumption (GH-260).

Closes #361

External iteration via Enumerator#next uses a Fiber, cheap on CRuby but
Fiber-per-row (native thread) on JRuby, so CSV.parse_line and CSV#each
are ~10x slower there. Drive the parser with a block on fresh iteration;
keep Enumerator#next only when #shift/#peek already started pull-based
iteration, preserving shared consumption (rubyGH-260).

Closes ruby#361
@kou

kou commented Jul 24, 2026

Copy link
Copy Markdown
Member

How about #363?

@donoghuc donoghuc closed this Jul 25, 2026
@donoghuc

donoghuc commented Jul 25, 2026

Copy link
Copy Markdown
Author

Closing in favor of pr linked above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JRuby performance regression for CSV.parse_line

2 participants